using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

namespace yWriter6
{
	[DesignerGenerated]
	public class frmHighlightColours : Form
	{
		private IContainer components;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdOk")]
		private Button _cmdOk;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdCancel")]
		private Button _cmdCancel;

		[CompilerGenerated]
		[AccessedThroughProperty("ListView1")]
		private ListView _ListView1;

		[CompilerGenerated]
		[AccessedThroughProperty("ColumnHeader1")]
		private ColumnHeader _ColumnHeader1;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdAdd")]
		private Button _cmdAdd;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdEdit")]
		private Button _cmdEdit;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdDelete")]
		private Button _cmdDelete;

		[CompilerGenerated]
		[AccessedThroughProperty("ColorDialog1")]
		private ColorDialog _ColorDialog1;

		internal virtual Button cmdOk
		{
			[CompilerGenerated]
			get
			{
				return _cmdOk;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdOk_Click;
				Button cmdOk = _cmdOk;
				if (cmdOk != null)
				{
					cmdOk.Click -= value2;
				}
				_cmdOk = value;
				cmdOk = _cmdOk;
				if (cmdOk != null)
				{
					cmdOk.Click += value2;
				}
			}
		}

		internal virtual Button cmdCancel
		{
			[CompilerGenerated]
			get
			{
				return _cmdCancel;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdCancel_Click;
				Button cmdCancel = _cmdCancel;
				if (cmdCancel != null)
				{
					cmdCancel.Click -= value2;
				}
				_cmdCancel = value;
				cmdCancel = _cmdCancel;
				if (cmdCancel != null)
				{
					cmdCancel.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("ListView1")]
		internal virtual ListView ListView1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("ColumnHeader1")]
		internal virtual ColumnHeader ColumnHeader1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		internal virtual Button cmdAdd
		{
			[CompilerGenerated]
			get
			{
				return _cmdAdd;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdAdd_Click;
				Button cmdAdd = _cmdAdd;
				if (cmdAdd != null)
				{
					cmdAdd.Click -= value2;
				}
				_cmdAdd = value;
				cmdAdd = _cmdAdd;
				if (cmdAdd != null)
				{
					cmdAdd.Click += value2;
				}
			}
		}

		internal virtual Button cmdEdit
		{
			[CompilerGenerated]
			get
			{
				return _cmdEdit;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdEdit_Click;
				Button cmdEdit = _cmdEdit;
				if (cmdEdit != null)
				{
					cmdEdit.Click -= value2;
				}
				_cmdEdit = value;
				cmdEdit = _cmdEdit;
				if (cmdEdit != null)
				{
					cmdEdit.Click += value2;
				}
			}
		}

		internal virtual Button cmdDelete
		{
			[CompilerGenerated]
			get
			{
				return _cmdDelete;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdDelete_Click;
				Button cmdDelete = _cmdDelete;
				if (cmdDelete != null)
				{
					cmdDelete.Click -= value2;
				}
				_cmdDelete = value;
				cmdDelete = _cmdDelete;
				if (cmdDelete != null)
				{
					cmdDelete.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("ColorDialog1")]
		internal virtual ColorDialog ColorDialog1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		public frmHighlightColours()
		{
			base.Load += frmHighlightColours_Load;
			InitializeComponent();
		}

		[DebuggerNonUserCode]
		protected override void Dispose(bool disposing)
		{
			try
			{
				if (disposing && components != null)
				{
					components.Dispose();
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}

		[System.Diagnostics.DebuggerStepThrough]
		private void InitializeComponent()
		{
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(yWriter6.frmHighlightColours));
			cmdOk = new System.Windows.Forms.Button();
			cmdCancel = new System.Windows.Forms.Button();
			ListView1 = new System.Windows.Forms.ListView();
			ColumnHeader1 = new System.Windows.Forms.ColumnHeader();
			cmdAdd = new System.Windows.Forms.Button();
			cmdEdit = new System.Windows.Forms.Button();
			cmdDelete = new System.Windows.Forms.Button();
			ColorDialog1 = new System.Windows.Forms.ColorDialog();
			SuspendLayout();
			cmdOk.Location = new System.Drawing.Point(180, 297);
			cmdOk.Name = "cmdOk";
			cmdOk.Size = new System.Drawing.Size(75, 31);
			cmdOk.TabIndex = 0;
			cmdOk.Text = "OK";
			cmdOk.UseVisualStyleBackColor = true;
			cmdCancel.Location = new System.Drawing.Point(12, 297);
			cmdCancel.Name = "cmdCancel";
			cmdCancel.Size = new System.Drawing.Size(75, 31);
			cmdCancel.TabIndex = 0;
			cmdCancel.Text = "Cancel";
			cmdCancel.UseVisualStyleBackColor = true;
			ListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[1]
			{
				ColumnHeader1
			});
			ListView1.Location = new System.Drawing.Point(12, 12);
			ListView1.Name = "ListView1";
			ListView1.Size = new System.Drawing.Size(243, 276);
			ListView1.TabIndex = 1;
			ListView1.UseCompatibleStateImageBehavior = false;
			ListView1.View = System.Windows.Forms.View.Details;
			ColumnHeader1.Text = "Highlight Colours";
			ColumnHeader1.Width = 290;
			cmdAdd.Location = new System.Drawing.Point(261, 39);
			cmdAdd.Name = "cmdAdd";
			cmdAdd.Size = new System.Drawing.Size(64, 33);
			cmdAdd.TabIndex = 2;
			cmdAdd.Text = "Add";
			cmdAdd.UseVisualStyleBackColor = true;
			cmdEdit.Location = new System.Drawing.Point(261, 78);
			cmdEdit.Name = "cmdEdit";
			cmdEdit.Size = new System.Drawing.Size(64, 33);
			cmdEdit.TabIndex = 2;
			cmdEdit.Text = "Edit";
			cmdEdit.UseVisualStyleBackColor = true;
			cmdDelete.Location = new System.Drawing.Point(261, 131);
			cmdDelete.Name = "cmdDelete";
			cmdDelete.Size = new System.Drawing.Size(64, 33);
			cmdDelete.TabIndex = 2;
			cmdDelete.Text = "Delete";
			cmdDelete.UseVisualStyleBackColor = true;
			base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 16f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			base.ClientSize = new System.Drawing.Size(328, 337);
			base.Controls.Add(cmdDelete);
			base.Controls.Add(cmdEdit);
			base.Controls.Add(cmdAdd);
			base.Controls.Add(ListView1);
			base.Controls.Add(cmdCancel);
			base.Controls.Add(cmdOk);
			DoubleBuffered = true;
			base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
			base.MaximizeBox = false;
			base.Name = "frmHighlightColours";
			Text = "Setup Highlight Colours";
			ResumeLayout(false);
		}

		private void frmHighlightColours_Load(object sender, EventArgs e)
		{
			FillList();
		}

		private void FillList()
		{
			ListView1.Items.Clear();
			int num = 0;
			Color color;
			do
			{
				num++;
				color = clsShared.cSettings.sGet("HighlightColour" + Conversions.ToString(num), Color.Empty);
				if (color != Color.Empty)
				{
					AddColourToList(color);
				}
			}
			while (!(color == Color.Empty));
			if (ListView1.Items.Count == 0)
			{
				AddColourToList(Color.Yellow);
			}
		}

		private void cmdCancel_Click(object sender, EventArgs e)
		{
			Hide();
			Application.DoEvents();
		}

		private void cmdOk_Click(object sender, EventArgs e)
		{
			SaveHighlightColours();
			Hide();
			Application.DoEvents();
		}

		private void SaveHighlightColours()
		{
			clsShared.cSettings.DeleteSettingsStartingWith("HighlightColour");
			int num = 0;
			IEnumerator enumerator = default(IEnumerator);
			try
			{
				enumerator = ListView1.Items.GetEnumerator();
				while (enumerator.MoveNext())
				{
					ListViewItem listViewItem = (ListViewItem)enumerator.Current;
					num++;
					clsShared.cSettings.sSet("HighlightColour" + Conversions.ToString(num), listViewItem.BackColor);
				}
			}
			finally
			{
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
			}
		}

		private void cmdAdd_Click(object sender, EventArgs e)
		{
			if (ColorDialog1.ShowDialog() == DialogResult.OK)
			{
				Color color = ColorDialog1.Color;
				AddColourToList(color);
			}
		}

		private void AddColourToList(Color NewColour)
		{
			ListViewItem listViewItem = ListView1.Items.Add("Highlight Colour " + Conversions.ToString(ListView1.Items.Count + 1));
			listViewItem.BackColor = NewColour;
			listViewItem.Tag = NewColour.ToArgb();
		}

		private void cmdEdit_Click(object sender, EventArgs e)
		{
			if (ListView1.FocusedItem != null)
			{
				ColorDialog1.Color = ListView1.FocusedItem.BackColor;
				if (ColorDialog1.ShowDialog() == DialogResult.OK)
				{
					ListView1.Items.RemoveAt(ListView1.FocusedItem.Index);
					Color color = ColorDialog1.Color;
					AddColourToList(color);
				}
			}
		}

		private void cmdDelete_Click(object sender, EventArgs e)
		{
			if (ListView1.FocusedItem != null)
			{
				ListView1.Items.RemoveAt(ListView1.FocusedItem.Index);
			}
		}
	}
}
